package master;

import java.util.List;

/**
 *
 * 删除排序链表中的重复元素
 *
 * @author chenyw
 * @date 2022/7/27 16:18
 */
public class M83deleteDuplicates {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode pre = new ListNode(-1);
        pre.next = head;
        ListNode p =head;
        while (p != null) {
            if (p.val != pre.val) {
                pre.next = p;
                pre = p;
            }
            if (p.next == null) {
                pre.next = null;
                break;
            }
            p = p.next;

        }
        return head;
    }

}
